<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title><%= name %>></title>
    <style type="text/css">
        #box{
            width: 350px;
            height: 200px;
            border: 1px solid #000;
            text-align: center;
            font-size: 76px;
            line-height: 200px;
        }
    </style>
    <script type="text/javascript" src="/lib/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="/lib/vue-2.5.3.min.js"></script>
</head>
<body>
    <div id="temp">
        <button id="btn">获取数据</button>
        <div id="box"></div>
        <hr>
        <p>{{text}}</p>
        <table>
            <tr>
                <td>id</td>
                <td>temp</td>
                <td>time</td>
            </tr>
            <tr v-for="item in tableList">
                <td>{{item.id}}</td>
                <td>{{item.temp}}</td>
                <td>{{item.time}}</td>
            </tr>
        </table>
    </div>
</body>
<script type="text/javascript">

    let vm = new Vue({
                el:'#temp',
                data : {
                    text: 'hello world!',
                    tableList:''
                },
                mounted: function(){
                    var that = this;
                    let btn = document.getElementById('btn');
                    btn.addEventListener('click',function(){
                        $.get('/sql?url=get_data',function(data,status){
                            console.log(data);
                            let temp = JSON.parse(data).data;
                            that.tableList = temp;
                            console.log(temp);
                            $('#box').html(temp[2].temp+'℃')
                        })
                    })
                }
        })
</script>

</html>